package algorithm.tree;

/**
 * 构造并遍历二叉树
 */
public class Traverse {
    public static void main(String[] args) {
        BinaryTree<String> bitree = create();
        bitree.preOrder();
        bitree.inOrder();
        bitree.postOrder();
    }

    public static BinaryTree create() {
        BinaryNode<String> child_f,child_d,child_b,child_c,child_a;
        child_f=new BinaryNode<String>("F",new BinaryNode("H"),null);
        child_d=new BinaryNode<String>("D",null,new BinaryNode("G"));
        child_b=new BinaryNode<String>("B",child_d,null);
        child_c=new BinaryNode<String>("C",new BinaryNode("E"),child_f);
        child_a=new BinaryNode<String>("A",child_b,child_c);
        return new BinaryTree(child_a);
    }
}
